package com.hxkj.cst.chengshuitong.ui.adapter

import android.support.v4.view.PagerAdapter
import android.util.SparseArray
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView

/**
 * 作者： Luoyang on 2017/5/25.
 * 描述： 引导页viewpager适配器
 */
class GuidePageAdapter(var sparseArray: SparseArray<ImageView>) : PagerAdapter() {
    override fun isViewFromObject(p0: View?, p1: Any?): Boolean = p0 == p1

    override fun getCount(): Int = sparseArray.size()

    override fun instantiateItem(container: ViewGroup?, position: Int): Any {
        val imageView = sparseArray[position]
        container?.addView(imageView)
        return imageView
    }

    override fun destroyItem(container: ViewGroup?, position: Int, `object`: Any?) {
        container?.removeView(sparseArray[position])
    }
}